<template>
  <div class="tagsEdit">
    <el-dialog title="修改目录" :visible.sync="visible" width="20%" close="close" :show-close="false" :close-on-click-modal="false">
      <el-form :model="editItem" :rules="rules" ref="ruleFormRefs" label-width="80px">
        <el-form-item label="所属学科">
          <el-select v-model="editItem.subjectName" placeholder="请选择">
            <el-option v-for="item in subjectList" :key="item.value" :label="item.label" :value="item.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="目录名称" prop="tagName">
          <el-input v-model="editItem.tagName"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="$emit('update:visible', false)">取 消</el-button>
        <el-button type="primary" @click="handleEdit">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { update } from '@/api/hmmm/tags'

export default {
  name: 'tagsEdit',
  props: {
    visible: {
      type: Boolean,
      required: true
    },
    subjectList: {
      type: Array,
      required: true
    },
    editItem: {
      type: Object,
      required: true
    }
  },
  components: {},
  data () {
    return {
      ruleForm: {
        name: '',
        region: ''
      },
      rules: {
        tagName: [
          { required: true, message: '请输入活动名称', trigger: 'blur' },
          { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
        ]
      },
      selectVal: ''
    }
  },
  watch: {},
  created () { },
  mounted () { },
  computed: {},
  methods: {
    close () {
      this.$refs.ruleFormRefs.resetFields()
      this.$emit('update:visible', false)
    },
    async handleEdit () {
      const res = await update(this.editItem)
      console.log(res)
      if (res.status !== 200) return this.$message.warning('修改失败!')
      this.$message.success('修改成功!')
      this.$emit('update:visible', false)
    }
  }
}
</script>

<style lang="less" scoped>
</style>
